//
//  DetailsAllCollectionController.swift
//  Live
//
//  Created by ly on 16/5/7.
//  Copyright © 2016年 ly. All rights reserved.
//


import UIKit
import SDWebImage

private let reuseIdentifier = "DetailsCell"

class DetailsAllCollectionController: UICollectionViewController {

    // MARK:- 属性
    //控制器的角标 用于分辨控制器
    var indexController = 0
    //接收模型
    var itmeArray : [DetailsItme]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        collectionView?.backgroundColor = UIColor.brownColor()
        //设置内边距
        collectionView?.contentInset = UIEdgeInsetsMake(titleScrollH + statusBarH, margin, 0, margin)
        collectionView?.showsHorizontalScrollIndicator = false
        collectionView?.showsVerticalScrollIndicator = false
        //注册cell
        collectionView?.registerNib(UINib(nibName: "DetailsCollectionCell", bundle: nil), forCellWithReuseIdentifier: reuseIdentifier)
        self.automaticallyAdjustsScrollViewInsets = false
        //网络请求
        HttpDemand.completeLoadData { (array) -> () in
            self.itmeArray = array as? [DetailsItme]
            self.collectionView?.reloadData()
        }
    }

    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
       
        return itmeArray?.count ?? 0
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! DetailsCollectionCell
        let itme = itmeArray![indexPath.row]
        cell.room_name.text = itme.room_name
        cell.room_src.setImageWithURL(NSURL(string: itme.room_src)!)
        return cell
    }

    
}



